using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class PerformanceTest_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(global::PerformanceTest);

            field = type.GetField("mesh", flag);
            app.RegisterCLRFieldGetter(field, get_mesh_0);
            app.RegisterCLRFieldSetter(field, set_mesh_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_mesh_0, AssignFromStack_mesh_0);
            field = type.GetField("mat", flag);
            app.RegisterCLRFieldGetter(field, get_mat_1);
            app.RegisterCLRFieldSetter(field, set_mat_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_mat_1, AssignFromStack_mat_1);
            field = type.GetField("TestScore", flag);
            app.RegisterCLRFieldGetter(field, get_TestScore_2);
            app.RegisterCLRFieldSetter(field, set_TestScore_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_TestScore_2, AssignFromStack_TestScore_2);


            app.RegisterCLRCreateDefaultInstance(type, () => new global::PerformanceTest());
            app.RegisterCLRCreateArrayInstance(type, s => new global::PerformanceTest[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }



        static object get_mesh_0(ref object o)
        {
            return ((global::PerformanceTest)o).mesh;
        }

        static StackObject* CopyToStack_mesh_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((global::PerformanceTest)o).mesh;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_mesh_0(ref object o, object v)
        {
            ((global::PerformanceTest)o).mesh = (UnityEngine.Mesh)v;
        }

        static StackObject* AssignFromStack_mesh_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Mesh @mesh = (UnityEngine.Mesh)typeof(UnityEngine.Mesh).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((global::PerformanceTest)o).mesh = @mesh;
            return ptr_of_this_method;
        }

        static object get_mat_1(ref object o)
        {
            return ((global::PerformanceTest)o).mat;
        }

        static StackObject* CopyToStack_mat_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((global::PerformanceTest)o).mat;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_mat_1(ref object o, object v)
        {
            ((global::PerformanceTest)o).mat = (UnityEngine.Material)v;
        }

        static StackObject* AssignFromStack_mat_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Material @mat = (UnityEngine.Material)typeof(UnityEngine.Material).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((global::PerformanceTest)o).mat = @mat;
            return ptr_of_this_method;
        }

        static object get_TestScore_2(ref object o)
        {
            return ((global::PerformanceTest)o).TestScore;
        }

        static StackObject* CopyToStack_TestScore_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((global::PerformanceTest)o).TestScore;
            __ret->ObjectType = ObjectTypes.Float;
            *(float*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_TestScore_2(ref object o, object v)
        {
            ((global::PerformanceTest)o).TestScore = (System.Single)v;
        }

        static StackObject* AssignFromStack_TestScore_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Single @TestScore = *(float*)&ptr_of_this_method->Value;
            ((global::PerformanceTest)o).TestScore = @TestScore;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new global::PerformanceTest();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
